package com.bz.redis.service.impl;

import com.bz.redis.service.ContentService;
import com.bz.vo.ContentVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ContentServiceImpl implements ContentService {

    @Autowired
    private RedisTemplate<String,Object> redisTemplate;

    private final String frontend_ad_redis_key = "frontend:ad:redis:key";

    /**
     * 将大广告位的数据添加到缓存中
     * @param contentVoList
     */
    @Override
    public void insertContentAD(List<ContentVo> contentVoList) {
        redisTemplate.opsForValue().set(frontend_ad_redis_key,contentVoList);
    }

    /**
     * 查询缓存中首页大广告位的数据
     * @return
     */
    @Override
    public List<ContentVo> selectContentAD() {
        return (List<ContentVo>)redisTemplate.opsForValue().get(frontend_ad_redis_key);
    }
}
